//
//  ZYTabBarViewController.m
//  commonProject
//
//  Created by 飞奔的羊 on 16/6/11.
//  Copyright © 2016年 itcast. All rights reserved.
//

#import "ZYTabBarViewController.h"
#import "ZYHomeViewController.h"
#import "ZYMySpaceViewController.h"
#import "ZYTabBarViewController.h"
#import "ZYAboutMeViewController.h"
#import "ZYPlayBarViewController.h"
@interface ZYTabBarViewController ()
/**
 *  <#Description#>
 */
@property (nonatomic,strong)UIButton *composeBtn;
@end

@implementation ZYTabBarViewController

- (void)viewDidLoad {
    [super viewDidLoad];
	self.view.backgroundColor = [UIColor whiteColor];
	self.tabBar.tintColor = [UIColor darkGrayColor];
	[self addController:[[ZYHomeViewController alloc]init] andTitle:@"首页" andImageName:@"tabbar_icon_auth"];
	[self addController:[[ZYAboutMeViewController alloc]init] andTitle:@"与我有关" andImageName:@"tabbar_icon_auth"];
	[self addChildViewController:[[UIViewController alloc]init]];
	
	[self addController:[[ZYMySpaceViewController alloc]init] andTitle:@"我的空间" andImageName:@"tabbar_icon_auth"];
	[self addController:[[ZYPlayBarViewController alloc]init] andTitle:@"玩吧" andImageName:@"tabbar_icon_auth"];
}

- (void)addController:(UIViewController *)controller andTitle:(NSString *)title andImageName:(NSString *)imageName
{
	
	controller.title = title;
	controller.tabBarItem.image = [UIImage imageNamed:imageName];
	NSString *seletedImage = [NSString stringWithFormat:@"%@_click",imageName];
	controller.tabBarItem.selectedImage = [[UIImage imageNamed:seletedImage] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
	UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:controller];
	[self addChildViewController:nav];
	

}
-(void)addComposeBtn
{
	[self.composeBtn setImage:[UIImage imageNamed:@"tabbar_btn"] forState:UIControlStateNormal];
	CGFloat itemWidth = self.tabBar.bounds.size.width / self.viewControllers.count;
	self.composeBtn.imageView.contentMode = UIViewContentModeScaleAspectFit;
	self.composeBtn.frame = CGRectInset(self.tabBar.bounds, itemWidth * 2, 0);
//	[self.composeBtn addTarget:self action:@selector(btnPlay) forControlEvents:UIControlEventTouchUpInside];
}
//监听 btn 的点击,不会调用这个方法
- (void)btnPlay
{}

- (UIButton *)composeBtn
{
	if (_composeBtn == nil) {
		_composeBtn = [UIButton new];
		[self.tabBar addSubview:_composeBtn];
	}
	return _composeBtn;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
